import time

from selenium import webdriver


# 链接数组
# csdn_list = ['141160706','140512204','141018218','141017577','141016931','140761691','140611047','140608945','140553054','140552530','140513255','140512541','140511903','140500865','140499591','140499201','140499065','140498595','135068227','135068012','135067451','134603845','134573768','134260724','131770696','131770545','131661256']

csdn_list = ['142516791','141160706','140512204']
# 15.打开两个页面execute_script("window.open('{}','_blank');".format('https://v220-dsr.21silkroad.com/login'))
# for i in csdn_list:
#     driver.execute_script("window.open('{}','_blank');".format('https://blog.csdn.net/m0_55341944/article/details/'+i))
#
# for j in range(100):
#     for i in csdn_list:
#         driver.execute_script("window.open('{}','_blank');".format('https://blog.csdn.net/m0_55341944/article/details/' + i))
#     time.sleep(30)
#     for i in range(len(csdn_list)):
#         print(i)
#         driver.switch_to_window(driver.window_handles[i-1])
#         driver.refresh()
# # 获取柄权switch_to_window(driver.window.handles[i])
# for i in range(11):
#     driver.switch_to_window(driver.window_handles[i])
#     driver.get('https://blog.csdn.net/m0_55341944/article/details/140553054?spm=1001.2014.3001.5502')
#     driver.get("https://blog.csdn.net/m0_55341944/article/details/140513255?spm=1001.2014.3001.5502")
#     driver.get("https://blog.csdn.net/m0_553419 44/article/details/140512541?spm=1001.2014.3001.5502")

def new_window_def():
    option = webdriver.ChromeOptions()
    option.add_argument('--headless')
    driver = webdriver.Chrome(options=option)
    # 设置全屏

    # driver.maximize_window()
    # driver.set_window_size(540,400)
    driver.implicitly_wait(5)
    driver.get('http://106.53.17.186:8080/login')
    for i in csdn_list:
        driver.execute_script("window.open('{}','_blank');".format('https://blog.csdn.net/m0_55341944/article/details/' + i))
        time.sleep(0.5)
    time.sleep(20)
    driver.close()
    driver.quit()
